﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MS.InformationManagement.Presenter.Support;
using MS.InformationManagement.BLL.DocumentGenerator;
using MS.InformationManagement.DAL.RecordCenter;

namespace MS.InformationManagement.Presenter.DocumentTypeUploader
{
    public class DocumentTypeUploaderPresenter : BasePresenter<IDocumentTypeUploaderView>
    {
        public DocumentTypeUploaderPresenter(IDocumentTypeUploaderView view) : base(view) { }

        public void AddDocumentType()
        {
            DocumentGeneratorBLL.SaveDocumentType(View.FileName, View.Title, View.Code, View.Version, View.CreationDate, View.FileInputStream);
        }

        public void UpdateDocumentType()
        {
            DocumentGeneratorBLL.UpdateDocumentType(View.ItemID.Value, View.FileName, View.Title, View.Code, View.Version, View.CreationDate, View.FileInputStream);
        }

        public void HandleLoad()
        {
            if (View.ItemID.HasValue)
            {
                TipoDocumental documentType = DocumentGeneratorBLL.GetDocumentType(View.ItemID.Value);
                View.Title = documentType.Title;
                View.Version = documentType.Versión;
                View.Code = documentType.Código;
                View.CreationDate = documentType.FechaDeCreación;
                View.Operation = "Actualizar Tipo de Documento";
            }
            else
            {
                View.Operation = "Agregar Tipo de Documento";
            }
        }
    }
}
